﻿<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="test_del.aspx.cs" Inherits="SQT.tracnghiem.Ajax.ASP.Certificate.test_del" %>

<%@ Import Namespace="DataAccess" %>
<!DOCTYPE html>

<html xmlns="http://www.w3.org/1999/xhtml">

<body>
    <% 
        int id = int.Parse(Request.QueryString["id"]);

        var get_result = new TblResultController().FetchAll().Where(x => x.TestId == id);
        foreach (TblResult result in get_result)
        {
            new TblResultController().Destroy(result.ResultId);
        }
        
        var get_td = new TblTestDetailController().FetchAll().Where(x => x.TestId == id);
        foreach (TblTestDetail td in get_td)
        {
            var get_ques = new TblQuestionController().FetchAll().Where(x => x.QuestionTestDetail == td.TestDetailId);
            foreach (TblQuestion ques in get_ques)
            {
                new TblQuestionController().Destroy(ques.QuestionId);
            }
            new TblTestDetailController().Destroy(td.TestDetailId);
        }
        new TblTestController().Destroy(id);
        %>
</body>
</html>
